home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / NET / IRDA / IRLMP.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  7KB  |  245 lines

  1. /*********************************************************************
  2.  *                
  3.  * Filename:      irlmp.h
  4.  * Version:       0.9
  5.  * Description:   IrDA Link Management Protocol (LMP) layer
  6.  * Status:        Experimental.
  7.  * Author:        Dag Brattli <dagb@cs.uit.no>
  8.  * Created at:    Sun Aug 17 20:54:32 1997
  9.  * Modified at:   Tue Apr  6 20:05:14 1999
  10.  * Modified by:   Dag Brattli <dagb@cs.uit.no>
  11.  * 
  12.  *     Copyright (c) 1998 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved.
  13.  *     
  14.  *     This program is free software; you can redistribute it and/or 
  15.  *     modify it under the terms of the GNU General Public License as 
  16.  *     published by the Free Software Foundation; either version 2 of 
  17.  *     the License, or (at your option) any later version.
  18.  *
  19.  *     Neither Dag Brattli nor University of Troms° admit liability nor
  20.  *     provide warranty for any of this software. This material is 
  21.  *     provided "AS-IS" and at no charge.
  22.  *
  23.  ********************************************************************/
  24.  
  25. #ifndef IRLMP_H
  26. #define IRLMP_H
  27.  
  28. #include <asm/param.h>  /* for HZ */
  29.  
  30. #include <linux/config.h>
  31. #include <linux/types.h>
  32.  
  33. #include <net/irda/irda.h>
  34. #include <net/irda/qos.h>
  35. #include <net/irda/irlap.h>
  36. #include <net/irda/irlmp_event.h>
  37. #include <net/irda/irqueue.h>
  38. #include <net/irda/discovery.h>
  39.  
  40. /* LSAP-SEL's */
  41. #define LSAP_MASK     0x7f
  42. #define LSAP_IAS      0x00
  43. #define LSAP_ANY      0xff
  44.  
  45. #define DEV_ADDR_ANY  0xffffffff
  46.  
  47. /* Predefined LSAPs used by the various servers */
  48. #define TSAP_IRLAN    0x05
  49. #define LSAP_IRLPT    0x06
  50. #define TSAP_IROBEX   0x07
  51. #define TSAP_IRCOMM   0x08
  52.  
  53. #define LMP_HEADER          2    /* Dest LSAP + Source LSAP */
  54. #define LMP_CONTROL_HEADER  4
  55. #define LMP_MAX_HEADER      (LAP_HEADER+LMP_HEADER)
  56.  
  57. #define LM_MAX_CONNECTIONS  10
  58.  
  59. #define LM_IDLE_TIMEOUT     2*HZ /* 2 seconds for now */
  60.  
  61. typedef enum {
  62.     S_PNP,
  63.     S_PDA,
  64.     S_COMPUTER,
  65.     S_PRINTER,
  66.     S_MODEM,
  67.     S_FAX,
  68.     S_LAN,
  69.     S_TELEPHONY,
  70.     S_COMM,
  71.     S_OBEX,
  72.     S_ANY,
  73.     S_END,
  74. } SERVICE;
  75.  
  76. typedef void (*DISCOVERY_CALLBACK1) (discovery_t *);
  77. typedef void (*DISCOVERY_CALLBACK2) (hashbin_t *);
  78.  
  79. typedef struct {
  80.     QUEUE queue; /* Must be first */
  81.  
  82.     __u16 hints; /* Hint bits */
  83. } irlmp_service_t;
  84.  
  85. typedef struct {
  86.     QUEUE queue; /* Must be first */
  87.  
  88.     __u16 hint_mask;
  89.  
  90.     DISCOVERY_CALLBACK1 callback1;
  91.     DISCOVERY_CALLBACK2 callback2;
  92. } irlmp_client_t;
  93.  
  94. struct lap_cb; /* Forward decl. */
  95.  
  96. /*
  97.  *  Information about each logical LSAP connection
  98.  */
  99. struct lsap_cb {
  100.     QUEUE queue;      /* Must be first */
  101.  
  102.     int   magic;
  103.  
  104.     int   connected;
  105.     int   persistent;
  106.  
  107.     struct irda_statistics stats;
  108.  
  109.     __u8  slsap_sel;   /* Source (this) LSAP address */
  110.     __u8  dlsap_sel;   /* Destination LSAP address (if connected) */
  111.  
  112.     struct sk_buff *tmp_skb; /* Store skb here while connecting */
  113.  
  114.     struct timer_list watchdog_timer;
  115.  
  116.     IRLMP_STATE     lsap_state;  /* Connection state */
  117.     struct notify_t notify;      /* Indication/Confirm entry points */
  118.     struct qos_info qos;         /* QoS for this connection */
  119.  
  120.     struct lap_cb *lap; /* Pointer to LAP connection structure */
  121. };
  122.  
  123. /*
  124.  *  Information about each registred IrLAP layer
  125.  */
  126. struct lap_cb {
  127.     QUEUE queue;      /* Must be first */
  128.  
  129.     int magic;
  130.     int reason;    /* LAP disconnect reason */
  131.  
  132.     IRLMP_STATE lap_state;
  133.  
  134.     struct irlap_cb *irlap;    /* Instance of IrLAP layer */
  135.     hashbin_t *lsaps;         /* LSAP associated with this link */
  136.  
  137.     __u8  caddr;  /* Connection address */
  138.      __u32 saddr;  /* Source device address */
  139.      __u32 daddr;  /* Destination device address */
  140.     
  141.     struct qos_info *qos;  /* LAP QoS for this session */
  142.     struct timer_list idle_timer;
  143. };
  144.  
  145. /*
  146.  *  Used for caching the last slsap->dlsap->handle mapping
  147.  */
  148. typedef struct {
  149.     int valid;
  150.  
  151.     __u8 slsap_sel;
  152.     __u8 dlsap_sel;
  153.     struct lsap_cb *lsap;
  154. } CACHE_ENTRY;
  155.  
  156. /*
  157.  *  Main structure for IrLMP
  158.  */
  159. struct irlmp_cb {
  160.     int magic;
  161.  
  162.     __u8 conflict_flag;
  163.     
  164.     discovery_t discovery_cmd; /* Discovery command to use by IrLAP */
  165.     discovery_t discovery_rsp; /* Discovery response to use by IrLAP */
  166.  
  167.     int free_lsap_sel;
  168.  
  169. #ifdef CONFIG_IRDA_CACHE_LAST_LSAP
  170.     CACHE_ENTRY cache;  /* Caching last slsap->dlsap->handle mapping */
  171. #endif
  172.     struct timer_list discovery_timer;
  173.  
  174.      hashbin_t *links;         /* IrLAP connection table */
  175.     hashbin_t *unconnected_lsaps;
  176.      hashbin_t *clients;
  177.     hashbin_t *services;
  178.  
  179.     hashbin_t *cachelog;
  180.     int running;
  181.  
  182.     spinlock_t lock;
  183.  
  184.     __u16_host_order hints; /* Hint bits */
  185. };
  186.  
  187. /* Prototype declarations */
  188. int  irlmp_init(void);
  189. void irlmp_cleanup(void);
  190. struct lsap_cb *irlmp_open_lsap( __u8 slsap, struct notify_t *notify);
  191. void irlmp_close_lsap( struct lsap_cb *self);
  192.  
  193. __u16 irlmp_service_to_hint(int service);
  194. __u32 irlmp_register_service(__u16 hints);
  195. int irlmp_unregister_service(__u32 handle);
  196. __u32 irlmp_register_client(__u16 hint_mask, DISCOVERY_CALLBACK1 callback1,
  197.                 DISCOVERY_CALLBACK2 callback2);
  198. int irlmp_unregister_client(__u32 handle);
  199. int irlmp_update_client(__u32 handle, __u16 hint_mask, 
  200.             DISCOVERY_CALLBACK1, DISCOVERY_CALLBACK2);
  201.  
  202. void irlmp_register_link(struct irlap_cb *, __u32 saddr, struct notify_t *);
  203. void irlmp_unregister_link(__u32 saddr);
  204.  
  205. int  irlmp_connect_request( struct lsap_cb *, __u8 dlsap_sel, 
  206.                 __u32 saddr, __u32 daddr,
  207.                 struct qos_info *, struct sk_buff *);
  208. void irlmp_connect_indication( struct lsap_cb *self, struct sk_buff *skb);
  209. void irlmp_connect_response( struct lsap_cb *, struct sk_buff *);
  210. void irlmp_connect_confirm( struct lsap_cb *, struct sk_buff *);
  211. struct lsap_cb *irlmp_dup(struct lsap_cb *self, void *instance);
  212.  
  213. void irlmp_disconnect_indication(struct lsap_cb *self, LM_REASON reason, 
  214.                  struct sk_buff *userdata);
  215. void irlmp_disconnect_request(struct lsap_cb *, struct sk_buff *userdata);
  216.  
  217. void irlmp_discovery_confirm(hashbin_t *discovery_log);
  218. void irlmp_discovery_request(int nslots);
  219. void irlmp_do_discovery(int nslots);
  220. discovery_t *irlmp_get_discovery_response(void);
  221.  
  222. void irlmp_data_request( struct lsap_cb *, struct sk_buff *);
  223. void irlmp_udata_request( struct lsap_cb *, struct sk_buff *);
  224. void irlmp_data_indication( struct lsap_cb *, struct sk_buff *);
  225. void irlmp_udata_indication( struct lsap_cb *, struct sk_buff *);
  226.  
  227. void irlmp_status_request(void);
  228. void irlmp_status_indication( LINK_STATUS link, LOCK_STATUS lock);
  229.  
  230. int  irlmp_slsap_inuse( __u8 slsap);
  231. __u8 irlmp_find_free_slsap(void);
  232. LM_REASON irlmp_convert_lap_reason( LAP_REASON);
  233.  
  234. __u32 irlmp_get_saddr(struct lsap_cb *self);
  235. __u32 irlmp_get_daddr(struct lsap_cb *self);
  236.  
  237. extern char *lmp_reasons[];
  238. extern int sysctl_discovery_slots;
  239. extern int sysctl_discovery;
  240. extern struct irlmp_cb *irlmp;
  241.  
  242. static inline hashbin_t *irlmp_get_cachelog(void) { return irlmp->cachelog; }
  243.  
  244. #endif
  245.